/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package qs.crm.modules.salChance.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Timestamp;

/**
* @website https://eladmin.vip
* @description /
* @author tong
* @date 2023-05-26
**/
@Entity
@Data
@Table(name="sal_chance")
public class SalChance implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`chc_id`")
    @ApiModelProperty(value = "机会编号")
    private Long chcId;

    @Column(name = "`chc_source`")
    @ApiModelProperty(value = "机会来源")
    private String chcSource;

    @Column(name = "`chc_cust_name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "客户名称")
    private String chcCustName;

    @Column(name = "`chc_title`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "机会概要")
    private String chcTitle;

    @Column(name = "`chc_rate`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "成功率")
    private Integer chcRate;

    @Column(name = "`chc_linkman`")
    @ApiModelProperty(value = "联系人")
    private String chcLinkman;

    @Column(name = "`chc_tel`")
    @ApiModelProperty(value = "联系电话")
    private String chcTel;

    @Column(name = "`chc_desc`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "机会描述")
    private String chcDesc;

    @Column(name = "`chc_create_id`",nullable = false)
    @NotNull
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @ApiModelProperty(value = "创建机会编号")
    private Long chcCreateId;

    @Column(name = "`chc_create_by`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "机会创建人")
    private String chcCreateBy;

    @Column(name = "`chc_create_date`",nullable = false)
    @NotNull
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp chcCreateDate;

    @Column(name = "`chc_due_id`")
    @ApiModelProperty(value = "机会处理编号")//随机编号
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long chcDueId;

    @Column(name = "`chc_due_to`")
    @ApiModelProperty(value = "处理人")
    private String chcDueTo;

    @Column(name = "`chc_due_date`")
    @CreationTimestamp
    @ApiModelProperty(value = "处理时间")
    private Timestamp chcDueDate;

    @Column(name = "`chc_status`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "处理状态")
    private String chcStatus;

    public void copy(SalChance source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
